package com.mc.algorithm;

import java.util.Scanner;

public class MatrixSearch {
	public static boolean search(int[][] array,int key){
		int row = array.length;
		int i = 0;
		int j = array[0].length-1;
		
		while(array[i][j]!=key){
			if(array[i][j]>key){
				if(j>0)
					j--;
				else
					break;//没查询到
			}
			else if(array[i][j]<key){
				if(i<row-1)
					i++;
				else
					break;
			}
		}
		if(array[i][j]==key)
			return true;
		return false;	
	}
	public static void main(String[] args) {
		int[][] array = new int[][]{
			{1,2,3,4},{2,3,4,5},{3,4,5,6},{4,5,6,7}
		};
		
		Scanner sc = new Scanner(System.in);
		int key = sc.nextInt();
		boolean result = MatrixSearch.search(array, key);
		System.out.println(result);
		String str1 = "hello";
		String str2 = "he"+"llo";
		System.out.println(str1==str2);
	}
}
